package org.example.maven.advice;

import org.example.maven.pojo.Result;
import org.example.maven.throwing.demoMode.DemoModelException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.ErrorResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    // 捕获演示模式异常
    @ExceptionHandler(DemoModelException.class)
    @ResponseBody
    public Result handleDemoModeException(DemoModelException e) {
        Result res=new Result();
        res.put("code",405);
        res.put("message",e.getMessage());
        return res;
    }
}
